Skip to content

Conversation

michaelpeng36
Copy link
Contributor

Adds SBOM manifest generation to the CI pipeline. The SBOM will only be generated for release builds or when the user overrides the SimulateReleaseBuild variable on ADO.

@michaelpeng36 michaelpeng36 requested a review from davidmrdavid May 5, 2023 22:05
@michaelpeng36 michaelpeng36 merged commit efc56c4 into main May 8, 2023
Comment on lines +28 to +55
- pwsh: |
$simulateReleaseBuild = $null
Write-Host "SimulateReleaseBuild set to $env:SimulateReleaseBuild"
if (-not([bool]::TryParse($env:SimulateReleaseBuild, [ref] $simulateReleaseBuild)))
{
throw "SimulateReleaseBuild can only be set to true or false."
}
$isReleaseBuild = $false
if ($env:BuildSourceBranchName -like "release_*" -or $simulateReleaseBuild)
{
$isReleaseBuild = $true
}
Write-Host "Setting IsReleaseBuild to $isReleaseBuild because SimulateReleaseBuild is $env:SimulateReleaseBuild"
Write-Host "##vso[task.setvariable variable=IsReleaseBuild]$isReleaseBuild"
Write-Host "IsReleaseBuild: $isReleaseBuild"
displayName: Set IsReleaseBuild pipeline variable
env:
SimulateReleaseBuild: $(SimulateReleaseBuild)

- pwsh: |
Import-Module ".\pipelineUtilities.psm1" -Force
Install-Dotnet
displayName: 'Install .NET 3.1'

- pwsh: |
Write-Host "IsReleaseBuild set to $env:IsReleaseBuild"
$isReleaseBuild = $false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we're assigning isReleaseBuild twice? In the first pwsh block, we do it based on the branch name and the simulateReleaseBuild variable. On the last pwsh block, we do it based on env:IsReleaseBuild.

What would happen is SimulateReleaseBuild is true but env:IsReleaseBuild were false? Wouldn't force IsReleaseBuild to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite. The intention of SimulateReleaseBuild is precisely to force the pipeline to emulate behavior as if IsReleaseBuild were set to true. There should never be a case following the first pwsh block where the SimulateReleaseBuild is true but IsReleaseBuild is false.

For the second pwsh block, the reason IsReleaseBuild pipeline variable is propagated to this step as an environment variable is because Linux agents don't always respect using the $(variableName) notation directly in the pwsh script, and variable values are not carried over between steps in ADO by default. Instead, we set the pipeline variable in the first pwsh block with the Write-Host "##vso[task.setvariable variable=IsReleaseBuild]$isReleaseBuild" statement, and set an environment variable equal to the pipeline variable in the env block of the second pwsh block.

SBOMUtilSASUrl: $(SBOMUtilSASUrl)

- pwsh: |
./test/E2E/Start-E2ETest.ps1 -NoBuild -UseCoreToolsBuildFromIntegrationTests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we ever call this without NoBuild?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so the Start-E2ETest.ps1 script is intended to be used for both local E2E test runs and in CI. The CI uses the -NoBuild flag since we have a distinct step dedicated to building the SDK, but it can be omitted for a local test run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants